package com.cj.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

@SuppressWarnings("serial")
public class Post extends Model<Post> {
	public static final Post me = new Post();
	
	public List<Post> getAllPosts() {
		String sql = "select p.*, d.deptName from post p left join department d on p.deptId = d.deptId";
		return find(sql);
	}

	public Integer getMaxID() {
		String sql = "select max(postId) from post";
		return Db.queryInt(sql);
	}
	
	public List<Post> getPostsByDept(int deptId) {
		String sql = "select * from post where deptId = ?";
		return find(sql, deptId);
	}
	
}
